/****************************************** 
  	 捕获横竖屏切换，画出相应的图
   *******************************************/
  
  //横竖屏
  var webviewHeight;
  var webviewWidth;
  var bbtChartHeightPercentage = 0.7;
  var bbtChartHeight;
  var bbtChartWidth;
  var detailChartHeight;
  var detailChartWidth;
  
  var portraitOrLandscape;
  var showTip;
  
  
  /* portraitScaleFactor, landScapeScaleFactor用来设置正常显示时每个刻度的大小适配屏幕 
  	 当竖屏时，定义显示 PORTRAIT_SCALE_FACTOR 个格为一宽屏，当横屏时显示 LANDSCAPE_SCALE_FACTOR 个格为一宽屏；
  	 由于当天为中间数，两边数据对称获取，因此PORTRAIT_SCALE_FACTOR，LANDSCAPE_SCALE_FACTOR 均为奇数。
  */
  var PORTRAIT_SCALE_FACTOR = 11;
  var LANDSCAPE_SCALE_FACTOR = 21;
  
  //SCREEN_WIDTH_SCALE: 默认初始显示几屏数据
  var SCREEN_WIDTH_SCALE = 3;  
  
  /* 可算出portraitbefore或after showDaysNum = [ (SCREEN_WIDTH_SCALE - 1) / 2 ] * PORTRAIT_SCALE_FACTOR 
  												+ (PORTRAIT_SCALE_FACTOR - 1) / 2 
  										   = (SCREEN_WIDTH_SCALE * PORTRAIT_SCALE_FACTOR - 1) / 2;
  */
  var portraitBeforeShowDaysNum = Math.round((SCREEN_WIDTH_SCALE * PORTRAIT_SCALE_FACTOR - 1) / 2);
  var portraitAfterShowDaysNum = Math.round((SCREEN_WIDTH_SCALE * PORTRAIT_SCALE_FACTOR - 1) / 2);
  var landscapeBeforeShowDaysNum = Math.round((SCREEN_WIDTH_SCALE * LANDSCAPE_SCALE_FACTOR - 1) / 2);
  var landscapeAfterShowDaysNum = Math.round((SCREEN_WIDTH_SCALE * LANDSCAPE_SCALE_FACTOR - 1) / 2);
  var showDaysTotalNum;

  function addOrientationChangeListener(){
  	var orientationEvent = "onorientationchange" in window ? "orientationchange" : "resize"; 
  	window.addEventListener(orientationEvent, screenOrientationChangeCallback,false);	
  }
  
  function screenOrientationChangeCallback() { 
  	setTimeout('doOrientationChange()', 100);	
  }
  
  function doOrientationChange(){
  	if(isLandscape()){  		  				 		
  		showBBTChart();
  		disableBBTChartDetail();  	
  	}
  	
  	if(isPortrait()){  		
  		showBBTChart();	
  		enableBBTChartDetail();
  		firstShowBBTChartDetail();
  	}
  	
  	//log();		
  }
  
  function log(){
  	alert("WIN.OUTW="+window.outerWidth+",WIN.OUTH="+window.outerHeight+",WIN.INW="+window.innerWidth+"WIN.INH="+window.innerHeight);	
  	alert("SCR.W"+screen.width+",SCR.H="+screen.height+",SCR.AVW="+screen.availWidth+",SCR.AVH="+screen.availHeight); 	
  }
  
  function isPortrait(){
  	if(isPortraitOrLandscape())  
  		return getScreenHeight() > getScreenWidth();
  	else
  		return false;
  }
  
  function isLandscape(){
  	if(isPortraitOrLandscape())  
  		return getScreenHeight() < getScreenWidth();
  	else
  		return false;
  }

  function isPortraitOrLandscape(){
  	return (window.orientation == 0 || window.orientation == 180 || window.orientation == -90 || window.orientation == 90);
  }
  
  function setLandscapeData(){
  	portraitOrLandscape = "landscape";
  	showDaysTotalNum = landscapeBeforeShowDaysNum + landscapeAfterShowDaysNum;
  	
  	bbtChartWidth =  getScreenWidth();
	bbtChartHeight = getScreenHeight();
  }
  
  function setPortraitData(){
  	portraitOrLandscape = "portrait";  

  	showDaysTotalNum = portraitBeforeShowDaysNum + portraitAfterShowDaysNum;
  	
  	bbtChartWidth =  getScreenWidth();
	bbtChartHeight = getScreenHeight() * bbtChartHeightPercentage;		
  }
  
  